const IS_PROD = process.env.NODE_ENV === 'production';
module.exports = {
    pages: {
        index: {
            entry: 'src/main.ts',
            template: `public/index.html`,
            filename: 'index.html',
            chunks: ["chunk-vendors", "chunk-common", "index", 'runtime~index'],
            title: '壁纸-来自联想锁屏'
        }
    },
    devServer: {
        sockHost: "localhost",
        disableHostCheck: true,
        port: 8080, // 端口号
        host: "0.0.0.0",
        https: false, // https:{type:Boolean}
        open: true, //配置自动启动浏览器
        proxy: {
            "/apis": {
                // target: "http://127.0.0.1:80/api/v1", // 需要请求的地址
                target: 'https://pc-store.lenovomm.cn', // 需要请求的地址
                changeOrigin: true, // 是否跨域
                pathRewrite: {
                    "^/apis": "" // 替换target中的请求地址，也就是说，在请求的时候，url用'/proxy'代替'http://ip.taobao.com'
                }
            },
        }
    },

    productionSourceMap: !IS_PROD,
    configureWebpack: config => {
        if (IS_PROD) {
            config.optimization.minimizer[0].options.terserOptions.compress.warnings = false
            config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true
            config.optimization.minimizer[0].options.terserOptions.compress.drop_debugger = true
            config.optimization.minimizer[0].options.terserOptions.compress.pure_funcs = ['console.log']
        }
    }
}